let BASEURL = "http://124.221.181.146:8001"
// let HeaterVal = "Bearer "
import {
	setToken,
	getsToken,
	romoveToke
} from '@/utils/token.js'

const request = (options) => {
	if (getsToken()) {
		return new Promise((resolve, reject) => {
			uni.request({
				url: BASEURL + options.url || "",
				method: options.method || "GET",
				data: options.data || {},
				header: {
					Authorization: "Bearer " + getsToken()
				}
			}).then(res => {
				resolve(res[1].data)
			}).catch(err => {
				reject(err)
			})
		})
	} else {
		return new Promise((resolve, reject) => {
			uni.request({
				url: BASEURL + options.url || "",
				method: options.method || "GET",
				data: options.data || {},
			}).then(res => {
				resolve(res[1].data)
			}).catch(err => {
				reject(err)
			})
		})
	}

}

export default request
